package main

import (
	"github.com/bingoohuang/gg/pkg/ss"
	"strings"
)

const netstatCmd = "netstat -atnp"
const ProgramNameCmd = "ps -p %s -wo args | tail -1"

func parseLine(line string) NetstatLine {
	fields := strings.Fields(line)
	return NetstatLine{
		Proto:          fields[0],
		Recv:           ss.ParseInt(fields[1]),
		Send:           ss.ParseInt(fields[2]),
		LocalAddress:   fields[3],
		ForeignAddress: fields[4],
		State:          fields[5],
		PidProgram:     fields[6],
	}
}
